﻿// The Nova Project by Ken Beckett.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php

using System.Collections.Generic;

using Nova.CodeDOM;

namespace Nova.UI
{
    /// <summary>
    /// The view model for a <see cref="CodeDOM.BlockDecl"/>.
    /// </summary>
    public class BlockDeclVM : BlockStatementVM
    {
        #region /* STATICS */

        internal static void AddViewModelMapping()
        {
            CreateViewModel.Add(typeof(BlockDecl),
                delegate(CodeObject codeObject, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary) { return new BlockDeclVM((BlockDecl)codeObject, isDescription, dictionary); });
        }

        #endregion

        #region /* CONSTRUCTORS */

        /// <summary>
        /// Create a view model instance for the specified <see cref="CodeDOM.BlockDecl"/>.
        /// </summary>
        public BlockDeclVM(BlockDecl blockDecl, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary)
            : base(blockDecl, isDescription, dictionary)
        { }

        #endregion

        #region /* PROPERTIES */

        /// <summary>
        /// The underlying <see cref="CodeDOM.BlockDecl"/> model.
        /// </summary>
        public BlockDecl BlockDecl
        {
            get { return (BlockDecl)CodeObject; }
        }

        #endregion

        #region /* METHODS */

        #endregion

        #region /* RENDERING */

        public override void Render(CodeRenderer renderer, RenderFlags flags)
        {
            if (flags.HasFlag(RenderFlags.Description))
                TypeRefBaseVM.RenderType(renderer, BlockDecl.GetType(), RenderFlags.None, this);
            else
                base.Render(renderer, flags);
        }

        protected override void RenderStatement(CodeRenderer renderer, RenderFlags flags)
        { }

        protected override void RenderAfter(CodeRenderer renderer, RenderFlags flags)
        {
            base.RenderAfter(renderer, flags | RenderFlags.SuppressNewLine);
        }

        public override void RenderToolTip(CodeRenderer renderer, RenderFlags flags)
        {
            TypeRefBaseVM.RenderType(renderer, CodeObject.GetType(), flags, this);
            RenderMessagesInToolTip(renderer, flags);
        }

        #endregion
    }
}
